To obtain information about whether a computer supports certain sound features, you should use the Gestalt function, documented in Inside Macintosh: Operating System Utilities . Sometimes, however, you might need information the Gestalt function is not able to provide. The Sound Manager provides a number of routines that you can use to obtain additional sound-related information.
You can obtain the version numbers of the Sound Manager and the MACE tools by calling the SndSoundManagerVersion and MACEVersion functions, respectively. You can obtain information about a sound channel and about all sound channels by calling the SndControl , SndChannelStatus , and SndManagerStatus functions, respectively.
The Sound Manager includes two routines-- SndGetSysBeepState and SndSetSysBeepState --that allow you to determine and alter the status of the system alert sound.
To play a sound resource using low-level Sound Manager routines, you need the address of the sound header stored in the sound resource. Sound Manager versions 3.0 and later provide the GetSoundHeaderOffset function that you can use to obtain that information.
You can use SndSoundManagerVersion to determine the version of the Sound Manager tools available on a computer.
FUNCTION SndSoundManagerVersion: NumVersion;
The SndSoundManagerVersion function returns a version number that contains the same information as in the first 4 bytes of a 'vers' resource. You might use the SndSoundManagerVersion function to determine if a computer has the enhanced Sound Manager, which is necessary for multichannel sound and for continuous plays from disk.
The trap macro and routine selector for the SndSoundManagerVersion function are
For information on how to use the SndSoundManagerVersion function to determine whether the enhanced Sound Manager is available, see "Obtaining Version Information" .
You can use MACEVersion to determine the version of the MACE tools available on a machine.
FUNCTION MACEVersion: NumVersion;
You can obtain information about a sound data type by using the SndControl function. In Sound Manager version 3.0 and later, however, you virtually never need to call SndControl . The capabilities that SndControl provides are either provided by the Gestalt function or are no longer supported. The SndControl function is documented here for completeness only.
FUNCTION SndControl (id: Integer; VAR cmd: SndCommand): OSErr;
The SndControl function sends a control command directly to the Sound Manager to get information about a specific data type. The available data types are specified by constants:
CONST
squareWaveSynth = 1; {square-wave data}
waveTableSynth = 3; {wave-table data}
sampledSynth = 5; {sampled-sound data}
You can call SndControl even if no channel has been created for the type of data you want to get information about. SndControl can be used with the availableCmd or versionCmd sound commands to request information. The requested information is returned in the sound command record specified by the cmd parameter.
The SndControl function can indicate only whether a particular data format supports some feature (for example, stereo output), not whether the available sound hardware also supports that feature. In general, you should use the Gestalt function to determine whether the sound features you need are available in the current operating environment.
In Sound Manager version 2.0, you can also use the totalLoadCmd and loadCmd commands to get information about the amount of CPU time consumed by sound-related processing. However, these commands are not very accurate and are not supported by version 3.0 and later.
See the list of sound commands in "Sound Command Numbers" for a complete description of the sound commands supported by SndControl .
You can use the SndChannelStatus function to determine the status of a sound channel.
FUNCTION SndChannelStatus (chan: SndChannelPtr;
theLength: Integer;
theStatus: SCStatusPtr): OSErr;
If the SndChannelStatus function executes successfully, the fields of the record specified by theStatus accurately describe the sound channel specified by chan .
The trap macro and routine selector for the SndChannelStatus function are
For information on the structure of a sound channel status record, see "Sound Channel Status Records" .
You can use the SndManagerStatus function to determine information about all sound channels currently allocated.
FUNCTION SndManagerStatus (theLength: Integer;
theStatus: SMStatusPtr): OSErr;
The SndManagerStatus function determines information about all currently allocated sound channels. If the SndManagerStatus function executes successfully, the fields of the record specified by theStatus accurately describe the current status of the Sound Manager.
You can use the SndGetSysBeepState procedure to determine if the system alert sound is enabled.
PROCEDURE SndGetSysBeepState (VAR sysBeepState: Integer);
You can use the SndSetSysBeepState function to set the state of the system alert sound.
FUNCTION SndSetSysBeepState (sysBeepState: Integer): OSErr;
You can use the SndSetSysBeepState function to temporarily disable the system alert sound while you play a sound and then enable the alert sound when you are done. The sysBeepState parameter should be set to either sysBeepDisable or sysBeepEnable .
If your application disables the system alert sound, be sure to enable it when your application gets a suspend event.
You can use the GetSoundHeaderOffset function to get the offset from the beginning of a sound resource to the embedded sound header.
FUNCTION GetSoundHeaderOffset (sndHdl: Handle;
VAR offset: LongInt): OSErr;
The GetSoundHeaderOffset function returns, in the offset parameter, the number of bytes from the beginning of the sound resource specified by the sndHdl parameter to the sound header that is contained within that resource. You might need this information if you want to use the address of that sound header in a sound command (such as the soundCmd or bufferCmd sound command).
The handle passed to GetSoundHeaderOffset does not have to be locked.
The GetSoundHeaderOffset function is available only in version 3.0 and later of the Sound Manager. See "Obtaining a Pointer to a Sound Header" for a function you can call in earlier versions of the Sound Manager to obtain the same information.
You can call the GetSoundHeaderOffset function at interrupt time.
The trap macro and routine selector for the GetSoundHeaderOffset function are
See Listing 1-37 for an example of calling GetSoundHeaderOffset.
| Previous | Chapter contents | Chapter top | Section top | Next |